var api = require('../../utils/api');
var utils = require('../../utils/utils');
Page({
    data: {
    },
    onLoad: function () {
        setInterval(() => {
            this.loadOrders()
        }, 10 * 1000)
    },
    onShow: function () {
        this.loadOrders()
    },
    onPullDownRefresh: function () {
        // 下拉刷新
        this.loadOrders()
    },
    loadOrders: function () {
        wx.showLoading({
            title: '正在加载'
        })
        wx.request({
            url: 'https://coin.it577.net/api/fcoin/orders',
            success: ({data}) => {
                wx.hideLoading()
                // 将订单结果数据格式化
                data.map(item => {
                    item.orders = utils.formatOrders(item.orders)
                    return item
                })
                // console.log(data)
                this.setData({
                    results: data
                })
            }
        })
    },
})